package org.bjou

import org.codehaus.groovy.grails.commons.*
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.HSSFSheet
import org.apache.poi.hssf.usermodel.HSSFRow
import org.apache.poi.hssf.usermodel.HSSFCell
import org.codehaus.groovy.grails.commons.GrailsDomainClass
import org.codehaus.groovy.grails.web.converters.ConverterUtil
import org.springframework.web.servlet.support.RequestContextUtils as RCU
import org.codehaus.groovy.grails.scaffolding.DomainClassPropertyComparator;
import org.apache.poi.hssf.usermodel.HSSFCellStyle
import org.apache.poi.hssf.usermodel.HSSFFont
import org.apache.poi.hssf.util.Region


import org.apache.poi.hssf.util.HSSFColor;


class XlsExportService {

    boolean transactional = true
    
    //导出课程查询结果
    def courseExport(out,courseList)
    {
        try
        {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("课程查询");
        
            
        HSSFRow row
        HSSFCell cell
        HSSFCellStyle style = wb.createCellStyle()
        HSSFFont font   =   wb.createFont()
        font.setFontHeightInPoints((short)12)
        font.setFontName("宋体")
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD) 
        style.setFont(font)
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        style.setFillBackgroundColor(HSSFColor.ORANGE.index)
        
        
        HSSFCellStyle titleStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)16)
        font.setFontName("楷体_GB2312")
        titleStyle.setFont(font)
        titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
        HSSFCellStyle cellStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)10)
        font.setFontName("宋体")
        cellStyle.setFont(font)
        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
 
	
        row = sheet.createRow(0)
        cell = row.createCell(0)
        cell.setCellValue("序号")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(1)
        cell.setCellValue("规则号")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(2)
        cell.setCellValue("入学学期")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(3)
        cell.setCellValue("专业名称")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(4)
        cell.setCellValue("课程ID")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(5)
        cell.setCellValue("课程名称")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(6)
        cell.setCellValue("学分")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(7)
        cell.setCellValue("课程类型")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(8)
        cell.setCellValue("课程性质")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(9)
        cell.setCellValue("考试单位类型")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(10)
        cell.setCellValue("开课学期")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(11)
        cell.setCellValue("试卷号")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(12)
        cell.setCellValue("试卷号B")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(13)
        cell.setCellValue("系部")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(14)
        cell.setCellValue("专业层次")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(15)
        cell.setCellValue("课程状态")
        cell.setCellStyle(titleStyle)
        
             cell = row.createCell(16)
        cell.setCellValue("责任教师")
        cell.setCellStyle(titleStyle)
        
            cell = row.createCell(17)
        cell.setCellValue("是否选课")
        cell.setCellStyle(titleStyle)
            
        
                                 
                               
        
        def i=1
         courseList.each{ ch ->
             
              row = sheet.createRow(i)
              cell = row.createCell(0)
              cell.setCellValue(i)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(1)
              cell.setCellValue(ch["ruleCode"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(2)
              cell.setCellValue(ch["entryTerm"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(3)
              cell.setCellValue(ch["majorName"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(4)
              cell.setCellValue(ch["courseId"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(5)
              cell.setCellValue(ch["courseName"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(6)
              cell.setCellValue(ch["credit"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(7)
              cell.setCellValue(ch["courseType"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(8)
              cell.setCellValue(ch["courseProperty"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(9)
              cell.setCellValue(ch["examType"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(10)
              cell.setCellValue(ch["courseTerm"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(11)
              cell.setCellValue(ch["examNumber"])
              cell.setCellStyle(cellStyle)
              
                  cell = row.createCell(12)
              cell.setCellValue(ch["examNumberB"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(13)
              cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
                  cell = row.createCell(14)
              cell.setCellValue(ch["majorLevel"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(15)
              cell.setCellValue(ch["courseStatus"])
              cell.setCellStyle(cellStyle)
              
                  cell = row.createCell(16)
              cell.setCellValue(ch["teacherName"])
              cell.setCellStyle(cellStyle)
              
                 cell = row.createCell(17)
              cell.setCellValue(ch["pickFlag"])
              cell.setCellStyle(cellStyle)
              
                 
              
             
              
              i++
         }
         
        def j = 0;  
        while(j!=18){  
            j++;  
           sheet.autoSizeColumn((short) j ); 
        } 
         
        
        
        wb.write(out);
        out.close()
        
        }
        catch (Exception ex){
         log.error "Error"+ex
         println "Error!"
        }
    }
    
    
    //导出资源大表
  
 def resourceExport(out,resourceList)
   {
        try
        {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("资源大表");
        
            
        HSSFRow row
        HSSFCell cell
        HSSFCellStyle style = wb.createCellStyle()
        HSSFFont font   =   wb.createFont()
        font.setFontHeightInPoints((short)12)
        font.setFontName("宋体")
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD) 
        style.setFont(font)
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        style.setFillBackgroundColor(HSSFColor.ORANGE.index)
        
        
        HSSFCellStyle titleStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)16)
        font.setFontName("楷体_GB2312")
        titleStyle.setFont(font)
        titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
        HSSFCellStyle cellStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)10)
        font.setFontName("宋体")
        cellStyle.setFont(font)
        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
        // // 序号	课程名称							
        row = sheet.createRow(0)
        cell = row.createCell(0)
        cell.setCellValue("序号")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(1)
        cell.setCellValue("课程名称")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(2)
        cell.setCellValue("开课单位")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(3)
        cell.setCellValue("课程类别")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(4)
        cell.setCellValue("实验")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(5)
        cell.setCellValue("学分")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(6)
        cell.setCellValue("年级专业")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(7)
        cell.setCellValue("责任教师")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(8)
        cell.setCellValue("教学部")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(9)
        cell.setCellValue("教材名称")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(10)
        cell.setCellValue("教材类型")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(11)
        cell.setCellValue("数量")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(12)
        cell.setCellValue("版次")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(13)
        cell.setCellValue("主编（讲）")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(14)
        cell.setCellValue("出版单位")
        cell.setCellStyle(titleStyle)
        
       
        
        def i=1
         resourceList.each{ ch ->
              row = sheet.createRow(i)
              cell = row.createCell(0)
              cell.setCellValue(i)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(1)
              cell.setCellValue(ch["courseName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(2)
              cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(3)
              cell.setCellValue(ch["courseType"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(4)
              //cell.setCellValue(ch["teacherName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(5)
              cell.setCellValue(ch["credit"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(6)
              cell.setCellValue(ch["majorName"] + " " + ch["majorLevel"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(7)
              cell.setCellValue(ch["teacherName"])
              cell.setCellStyle(cellStyle)
              
              
              cell = row.createCell(8)
              cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(9)
              //cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(10)
              //cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(11)
             // cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(12)
              //cell.setCellValue(userBaseinfoInstance.mobile)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(13)
              //cell.setCellValue(userBaseinfoInstance.userGroup?.groupName)
              cell.setCellStyle(cellStyle)
//              
//              cell = row.createCell(14)
//              cell.setCellValue(ch[1].courseName)
//              cell.setCellStyle(cellStyle)
//              
//              cell = row.createCell(15)
//              cell.setCellValue(ch[1].majorLevel)
//              cell.setCellStyle(cellStyle)
//              
//              cell = row.createCell(16)
//              cell.setCellValue(ch[1].department?.departmentName)
//              cell.setCellStyle(cellStyle)
              
              i++
         }
         
        def j = 0;  
        while(j!=16){  
            j++;  
           sheet.autoSizeColumn((short) j ); 
        } 
         
        
        
        wb.write(out);
        out.close()
        
        }
        catch (Exception ex){
         log.error "Error"+ex
         println "Error!"
        }
   }
    
     
   def assignExport(out,assignList)
    {   
        try
        {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("教师信息表");
        
            
        HSSFRow row
        HSSFCell cell
        HSSFCellStyle style = wb.createCellStyle()
        HSSFFont font   =   wb.createFont()
        font.setFontHeightInPoints((short)12)
        font.setFontName("宋体")
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD) 
        style.setFont(font)
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        style.setFillBackgroundColor(HSSFColor.ORANGE.index)
        
        
        HSSFCellStyle titleStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)16)
        font.setFontName("楷体_GB2312")
        titleStyle.setFont(font)
        titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
        HSSFCellStyle cellStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)10)
        font.setFontName("宋体")
        cellStyle.setFont(font)
        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
        //	
        row = sheet.createRow(2)
        cell = row.createCell(0)
        cell.setCellValue("序号")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(1)
        cell.setCellValue("姓名")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(2)
        cell.setCellValue("性别")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(3)
        cell.setCellValue("身份证")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(4)
        cell.setCellValue("出生日期")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(5)
        cell.setCellValue("毕业院校")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(6)
        cell.setCellValue("专业")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(7)
        cell.setCellValue("学历")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(8)
        cell.setCellValue("专业技术职务")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(9)
        cell.setCellValue("所在单位")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(10)
        cell.setCellValue("电子邮箱")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(11)
        cell.setCellValue("座机联系")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(12)
        cell.setCellValue("手机联系")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(13)
        cell.setCellValue("类别")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(14)
        cell.setCellValue("课程名称")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(15)
        cell.setCellValue("类型")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(16)
        cell.setCellValue("开课单位")
        cell.setCellStyle(titleStyle)
        
        def i=3
         assignList.each{ ch ->
             def userBaseinfoInstance  =  UserBaseinfo.get(ch[0].id)
              row = sheet.createRow(i)
              cell = row.createCell(0)
              cell.setCellValue(i-2)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(1)
              cell.setCellValue(userBaseinfoInstance.fullname)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(2)
              cell.setCellValue(userBaseinfoInstance.gentle)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(3)
              cell.setCellValue(userBaseinfoInstance.idCard)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(4)
              cell.setCellValue(userBaseinfoInstance.birthday)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(5)
              cell.setCellValue(userBaseinfoInstance.school)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(6)
              cell.setCellValue(userBaseinfoInstance.majorName)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(7)
              cell.setCellValue(userBaseinfoInstance.degree)
              cell.setCellStyle(cellStyle)
              
              
              cell = row.createCell(8)
              cell.setCellValue(userBaseinfoInstance.proTitle)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(9)
              cell.setCellValue(userBaseinfoInstance.companyName)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(10)
              cell.setCellValue(userBaseinfoInstance.email)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(11)
              cell.setCellValue(userBaseinfoInstance.tel)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(12)
              cell.setCellValue(userBaseinfoInstance.mobile)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(13)
              cell.setCellValue(userBaseinfoInstance.userGroup?.groupName)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(14)
              cell.setCellValue(ch[1].courseName)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(15)
              cell.setCellValue(ch[1].majorLevel)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(16)
              cell.setCellValue(ch[1].department?.departmentName)
              cell.setCellStyle(cellStyle)
              
              i++
         }
         
        def j = 0;  
        while(j!=16){  
            j++;  
           sheet.autoSizeColumn((short) j ); 
        } 
         
        
        
        wb.write(out);
        out.close()
        
        }
        catch (Exception ex){
         log.error "Error"+ex
         println "Error!"
        }
        
       
    }
    
    
      
  
 def branchPickExport(out,resourceList)
   {
        try
        {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("选课查询");
        
            
        HSSFRow row
        HSSFCell cell
        HSSFCellStyle style = wb.createCellStyle()
        HSSFFont font   =   wb.createFont()
        font.setFontHeightInPoints((short)12)
        font.setFontName("宋体")
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD) 
        style.setFont(font)
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        style.setFillBackgroundColor(HSSFColor.ORANGE.index)
        
        
        HSSFCellStyle titleStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)16)
        font.setFontName("楷体_GB2312")
        titleStyle.setFont(font)
        titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
        HSSFCellStyle cellStyle = wb.createCellStyle()
        font   =   wb.createFont()
        font.setFontHeightInPoints((short)10)
        font.setFontName("宋体")
        cellStyle.setFont(font)
        cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)
        
     					
        row = sheet.createRow(0)
        cell = row.createCell(0)
        cell.setCellValue("序号")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(1)
        cell.setCellValue("规则号")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(2)
        cell.setCellValue("专业名称")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(3)
        cell.setCellValue("课程ID")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(4)
        cell.setCellValue("课程名称")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(5)
        cell.setCellValue("学分")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(6)
        cell.setCellValue("课程类型")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(7)
        cell.setCellValue("课程性质")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(8)
        cell.setCellValue("考试单位类型")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(9)
        cell.setCellValue("开课学期")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(10)
        cell.setCellValue("系部")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(11)
        cell.setCellValue("专业层次")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(12)
        cell.setCellValue("课程状态")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(13)
        cell.setCellValue("选课轮次")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(14)
        cell.setCellValue("任课教师")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(15)
        cell.setCellValue("教师职称")
        cell.setCellStyle(titleStyle)
        
        cell = row.createCell(16)
        cell.setCellValue("电话")
        cell.setCellStyle(titleStyle)
        
            
        cell = row.createCell(17)
        cell.setCellValue("人数")
        cell.setCellStyle(titleStyle)
        
       
        
        def i=1
         resourceList.each{ ch ->
              row = sheet.createRow(i)
              cell = row.createCell(0)
              cell.setCellValue(i)
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(1)
              cell.setCellValue(ch["ruleCode"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(2)
              cell.setCellValue(ch["majorName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(3)
              cell.setCellValue(ch["courseId"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(4)
              cell.setCellValue(ch["courseName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(5)
              cell.setCellValue(ch["credit"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(6)
              cell.setCellValue(ch["courseType"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(7)
              cell.setCellValue(ch["courseProperty"])
              cell.setCellStyle(cellStyle)
              
              
              cell = row.createCell(8)
              cell.setCellValue(ch["examType"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(9)
              cell.setCellValue(ch["courseTerm"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(10)
              cell.setCellValue(ch["departmentName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(11)
              cell.setCellValue(ch["majorLevel"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(12)
              cell.setCellValue(ch["roundFlag"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(13)
              cell.setCellValue(ch["courseStatus"])
              cell.setCellStyle(cellStyle)
             
              cell = row.createCell(14)
              cell.setCellValue(ch["teacherName"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(15)
              cell.setCellValue(ch["teacherTitle"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(16)
              cell.setCellValue(ch["teacherTel"])
              cell.setCellStyle(cellStyle)
              
              cell = row.createCell(17)
              cell.setCellValue(ch["teacherQty"])
              cell.setCellStyle(cellStyle)
              
              i++
         }
         
        def j = 0;  
        while(j!=16){  
            j++;  
           sheet.autoSizeColumn((short) j ); 
        } 
         
        
        
        wb.write(out);
        out.close()
        
        }
        catch (Exception ex){
         log.error "Error"+ex
         println "Error!"
        }
   }
}
